DAY11:Disemvowel Trolls


Posted by birdbirdmurmur on 2023-07-24

題目連結:

Disemvowel Trolls

解法:

初版

function disemvowel(str) {
  return str.replace(/[aeiouAEIOU]/g, '');
}

修正版

function disemvowel(str) {
  return str.replace(/[aeiou]/gi, '');
}

筆記:

使用replace做替換
修正版從/g/gi
從全域變成全域不分大小寫


#javascript #Codewars #replace







Related Posts

TCP/IP 四層模型/ HTTP 相關筆記

TCP/IP 四層模型/ HTTP 相關筆記

Day07  心得與Update/搜尋功能實作

Day07 心得與Update/搜尋功能實作

Fun with HTML5 Canvas

Fun with HTML5 Canvas


Comments